﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bot.Application.Dto;
using Bot.Application.Services;
using Microsoft.AspNetCore.Mvc;

namespace Bot.WebAPI.Controllers
{
    [Route("api/v3/agentAssist/synonyms")]
    [ApiController]
    public class AgentAssistSynonymKeywordsController : ControllerBase
    {

        private readonly ISynonymKeywordAppService _app;
        public AgentAssistSynonymKeywordsController(ISynonymKeywordAppService app)
        {
            this._app = app;
        }

        [HttpGet("{id}")]
        public ActionResult<SynonymKeywordDto> Get([FromRoute] Guid id)
        {
            SynonymKeywordDto synonymKeyword = _app.Get(id);
            return Ok(synonymKeyword);
        }

        [HttpGet]
        public ActionResult<IEnumerable<SynonymKeywordDto>> GetList()
        {
            IEnumerable<SynonymKeywordDto> list = _app.List();
            return Ok(list);
        }

        [HttpPut("{id}")]
        public ActionResult<SynonymKeywordDto> Put([FromRoute] Guid id, [FromBody] SynonymKeywordUpdateDto dto)
        {
            SynonymKeywordDto synonymKeyword = _app.Update(id, dto);
            return Ok(synonymKeyword);
        }

        [HttpPost]
        public ActionResult<SynonymKeywordDto> Post([FromBody] SynonymKeywordCreateDto dto)
        {
            SynonymKeywordDto synonymKeyword = _app.Add(dto);
            return CreatedAtAction(nameof(Get), new { id = synonymKeyword.Id }, synonymKeyword);
        }
        [HttpDelete("{id}")]
        public ActionResult Delete([FromRoute] Guid id)
        {
            _app.Delete(id);
            return NoContent();
        }
    }
}
